package sctu.edu.java.year2016.team04.guoyicheng.day20160521.chapter4_3;

/**
 * Created by yicheng on 2016/5/21.
 * 编写java程序，利用while循环语句计算1+1/2!+1/3!+1/4!....1/20!之和
 */
public class Java {
    public static void main(String args[])

    {
        double sum = 0, a = 1;
        int i = 1;
        while (i <= 20) {
            sum = sum + a;
            i = i + 1;
            a = a * (1.0 / i);
        }
        System.out.println(sum);
    }
}

